<?php


namespace Yond\LaravelDomain\Models\Concerns;

use Illuminate\Database\Eloquent\Builder;
use Spatie\SchemalessAttributes\SchemalessAttributes;

/**
 * Trait HasExtra
 * @mixin Model
 */
trait HasExtra
{
    public function initializeHasExtra()
    {
        $this->mergeCasts([
            'extra' => 'array',
        ]);
    }
    public function getExtraAttribute(): SchemalessAttributes
    {
        return SchemalessAttributes::createForModel($this, 'extra');
    }

    public function scopeWithExtra(): Builder
    {
        return SchemalessAttributes::scopeWithSchemalessAttributes('extra');
    }
}